<!-- 用户管理 -->
<template>
  <div class="app-container">
    <div class="search-bar">
      <el-form ref="queryFormRef" :model="queryParams" :inline="true">
        <el-form-item label="关键字" prop="pickupAddress">
          <el-input
            v-model="queryParams.pickupAddress"
            placeholder="关键字"
            clearable
            style="width: 200px"
            @keyup.enter="handleQuery"
          />
        </el-form-item>

        <el-form-item>
          <el-button type="primary" icon="search" @click="handleQuery">搜索</el-button>
          <el-button icon="refresh" @click="handleResetQuery">重置</el-button>
        </el-form-item>
      </el-form>
    </div>

    <el-card shadow="never">
      <el-table v-loading="loading" :data="pageData" @selection-change="handleSelectionChange">
        <el-table-column type="selection" width="50" align="center" />
        <el-table-column label="名称" prop="storeName" align="center" />
        <el-table-column label="手机号" prop="storeNo" align="center"></el-table-column>
        <el-table-column label="地址" prop="pickupAddress" align="center" />
      </el-table>

      <pagination
        v-if="total > 0"
        v-model:total="total"
        v-model:page="queryParams.pageNum"
        v-model:limit="queryParams.pageSize"
        @pagination="handleQuery"
      />
    </el-card>
  </div>
</template>

<script setup lang="ts">
import AddressAPI, { GoodsPageQuery } from "@/api/system/address.api";

defineOptions({
  name: "Order",
  inheritAttrs: false,
});
const queryFormRef = ref();

const queryParams = reactive<GoodsPageQuery>({
  page: 1,
  pageSize: 10,
});

const pageData = ref<any[]>();
const total = ref(0);
const loading = ref(false);

// 查询
function handleQuery() {
  loading.value = true;
  AddressAPI.getList(queryParams)
    .then((data) => {
      console.log(data);
      pageData.value = data;
      total.value = data.length;
    })
    .finally(() => {
      loading.value = false;
    });
}

// 重置查询
function handleResetQuery() {
  queryFormRef.value.resetFields();
  queryParams.pageNum = 1;
  handleQuery();
}

onMounted(() => {
  handleQuery();
});
</script>
